package behavioral_pattern.mediator_pattern.concrete_mediator;

import behavioral_pattern.mediator_pattern.colleague.IDepartment;
import behavioral_pattern.mediator_pattern.mediator.IMediator;

public class ConcreteMediator implements IMediator {
    IDepartment sale;
    IDepartment stock;
    IDepartment purchase;
    @Override
    public void operate(String type, Integer num) {
        if (IDepartment.COMMUNICATION_TYPE_ADD_PRODUCT.equals(type)) {
            //System.out.println("通知库存补货");
            stock.work(num);
        } else if (IDepartment.COMMUNICATION_TYPE_PURCHASE.equals(type)) {
            //System.out.println("通知采购部门补货");
            purchase.work(num);
        } else if (IDepartment.COMMUNICATION_TYPE_ADD_PRODUCT_FINISH.equals(type)) {
            //System.out.println("通知销售部门和库存, 补货完成");
            sale.communicat(type);
        } else if (IDepartment.COMMUNICATION_TYPE_PURCHASEING.equals(type)) {
            //System.out.println("通知销售部门, 库存不足, 采购中....");
            sale.communicat(type);
        } else if (IDepartment.COMMUNICATION_TYPE_PURCHASE_FINISH.equals(type)) {
            System.out.println("采购完成, 可以取货");
        }
    }

    public IDepartment getSale() {
        return sale;
    }

    public void setSale(IDepartment sale) {
        this.sale = sale;
    }

    public IDepartment getStock() {
        return stock;
    }

    public void setStock(IDepartment stock) {
        this.stock = stock;
    }

    public IDepartment getPurchase() {
        return purchase;
    }

    public void setPurchase(IDepartment purchase) {
        this.purchase = purchase;
    }
}
